package com.inspur.ourhis_afterend.Controller;

import com.inspur.ourhis_afterend.Service.RegisterOrderService;
import com.inspur.ourhis_afterend.Tools.PageAction;
import com.inspur.ourhis_afterend.Tools.Result;
import com.inspur.ourhis_afterend.model.RegisterOrder;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/register")
public class RegisterOrderController {
    @Resource(name = "registerOrderServiceImpl")
    RegisterOrderService registerOrderService;
    @ApiOperation("添加预约挂号同时添加创建医嘱，创建药表")
    @ApiParam(value = "获取信息")
    @PostMapping("/add")
    public Result addRegister(@RequestBody RegisterOrder registerOrder){
        try {
            return Result.success(registerOrderService.insertSelective(registerOrder));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.failure(e.toString());
        }
    }
    @ApiOperation("挂号管理动态模糊查询")
    @ApiParam(value = "条件动态模糊查询")
    @PostMapping("/search")
    public Result selectSelective(@RequestParam(value = "roid",required = false) Integer roid,
                                  @RequestParam(value = "memeberid",required = false) Integer memeberid,
                                  @RequestParam(value = "deptName",required = false) String deptName ,
                                  @RequestParam(value = "rotime",required = false) String rotime,
                                  @RequestBody PageAction pageAction){

        try {
            return Result.success(registerOrderService.selectReSelective(roid, memeberid, deptName, rotime, pageAction));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.failure(e.toString());
        }
    }
    @ApiOperation("挂号管理删除")
    @ApiParam(value = "roid")
    @PostMapping("/deleteRegister")
    public Result deleteRegister(@RequestParam("roid")Integer roid){
        try {
            return Result.success(registerOrderService.deleteByPrimaryKey(roid));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.failure(e.toString());
        }
    }

}
